from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.


class User(AbstractUser):
    """用户模型类"""
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    personal_url = models.CharField(max_length=100, verbose_name='个人网址', null=True)
    nickname = models.CharField(max_length=20, verbose_name='昵称', null=True)
    email = models.CharField(max_length=20, unique=True, verbose_name='邮箱', null=True)
    email_active = models.IntegerField(verbose_name='邮箱验证状态', default=0)
    avatar_url = models.CharField(max_length=100, verbose_name='头像地址', null=True)

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name


class UserCollect(models.Model):
    COLLECTION_TYPE = (
        (1, '头条'),
        (2, '吐槽')
    )
    user = models.ForeignKey(User, verbose_name='用户id')
    collect_type = models.IntegerField(choices=COLLECTION_TYPE,verbose_name='收藏类型')
    from headline.models import Headlines
    from spit.models import Spit
    headline = models.ForeignKey(Headlines, verbose_name='头条', null=True)
    spit = models.ForeignKey(Spit, verbose_name='吐槽', null=True)

    class Meta:
        db_table = 'tb_users_collect'
        verbose_name = '用户收藏关系'
        verbose_name_plural = verbose_name
